//
//  YKProcessTrackingViewController.m
//  YunKang
//
//  Created by leoking870 on 2017/10/3.
//  Copyright © 2017年 leoking870. All rights reserved.
//

#import "YKProcessTrackingViewController.h"
#import "YKClientListHeaderView.h"
#import "YKPopupView.h"
#import "YKProcessTrackingItem.h"

@interface YKProcessTrackingViewController ()

@end

@implementation YKProcessTrackingViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
//    YKClientListHeaderView* headerView = [[YKClientListHeaderView alloc]initWithTitles:@[@"流程节点",@"审批人",@"审批意见",@"审批时间"] weights:@[@1,@1,@1,@1]];
//    headerView.textFont = [UIFont systemFontOfSize:16];
//    headerView.backgroundColor = [UIColor tf_colorWithHexString:@"#1EADFC"];
//    headerView.textColor = [UIColor whiteColor];
//    [self.view addSubview:headerView];
//    [headerView mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.leading.top.trailing.equalTo(self.view);
//    }];
    
    UIButton *confirmButton = [[UIButton alloc]init];
    [confirmButton setTitle:@"确定" forState:UIControlStateNormal];
    [confirmButton setBackgroundColor:TFSTYLE(buttonEnableBackgroundColor)];
    [confirmButton setTitleColor:TFSTYLE(buttonEnableTitleColor) forState:UIControlStateNormal];
    [self.view addSubview:confirmButton];
    [confirmButton addTarget:self action:@selector(onConfirmButtonTapped:) forControlEvents:UIControlEventTouchUpInside];
    [confirmButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.bottom.trailing.equalTo(self.view);
        make.height.mas_equalTo(40);
    }];
    confirmButton.titleLabel.font = [UIFont systemFontOfSize:14];
    confirmButton.layer.cornerRadius = 5;
    
    [self.tableView mas_remakeConstraints:^(MASConstraintMaker *make) {
//        make.top.equalTo(headerView.mas_bottom);
        make.leading.top.trailing.equalTo(self.view);
        make.bottom.equalTo(confirmButton.mas_top);
    }];
    
    [self tf_showStateView:kTFViewStateLoading];
    [TFHTTPMANAER POST:@"workExamine/processTracking.htm" parameters:@{@"businessId":self.m_id} success:^(id responseObject) {
        NSArray *trackings = [NSArray yy_modelArrayWithClass:[YKProcessTrackingModel class] json:responseObject[@"wftrack"]];
        
        TFTableViewSection *section = [TFTableViewSection section];
        for (YKProcessTrackingModel *model in trackings) {
            YKProcessTrackingItem *item = [YKProcessTrackingItem itemWithModel:model];
            [section addItem:item];
        }
        section.headerHeight = .1f;
        section.footerHeight = .1f;
        [self.tableViewManager addSection:section];
        [self.tableView reloadData];
        [self tf_showStateView:kTFViewStateNone];
    } failure:^(id responseObject, NSError *error) {
        //[self tf_showStateView:kTFViewStateNetError];
        [self tf_showStateView:kTFViewStateNone];
        [self showHint:error.localizedFailureReason];
    }];
    
    
}

- (void)onConfirmButtonTapped:(id)sender {
    [YKPopupView dismissViewController:self];
}


@end
